package com.zenchn.service.impl;

import com.zenchn.dao.TSysConfigMapper;
import com.zenchn.dynamic.TSysConfigDynamicMapper;
import com.zenchn.generic.GenericDao;
import com.zenchn.generic.GenericServiceImpl;
import com.zenchn.model.TSysConfig;
import com.zenchn.model.TSysConfigExample;
import com.zenchn.service.ConfigService;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import static org.mybatis.dynamic.sql.SqlBuilder.*;
import static com.zenchn.dynamic.TSysConfigDynamicSqlSupport.*;
/**
 * 基础参数 业务实现类
 *
 * @author dingxinfa
 * @date 2020-04-16
 **/
@Service
@Transactional(rollbackFor = Exception.class)
public class ConfigServiceImpl  extends GenericServiceImpl<TSysConfig, String, TSysConfigExample> implements ConfigService {


    @Resource
    private TSysConfigMapper configMapper;

    @Resource
    private TSysConfigDynamicMapper configDynamicMapper;
    @Override
    public GenericDao<TSysConfig, String, TSysConfigExample> getDao() {
        return configMapper;
    }

    @Override
    public Boolean verifyConfigCode(String configId, String configCode) {

        TSysConfigExample example=new TSysConfigExample();
        TSysConfigExample.Criteria criteria=example.createCriteria();

        criteria.andConfigCodeEqualTo(configCode);
        if(null!=configId && !"".equals(configId.trim())){
            criteria.andConfigIdNotEqualTo(configId.trim());
        }

        return configMapper.countByExample(example) <= 0;

    }
}
